<template>
  <div class="fss">
    <div class="cover pr">
      <img :src="`${detail.picUrl}?param=177y177`" />
      <i class="icon_album_head_cover_mask pa mask"></i>
    </div>
    <div class="message">
      <div class="row1 fsc">
        <i class="icon_album_head_u_icon"></i>
        <span class="name">{{ detail.name }}</span>
      </div>
      <div class="row2">
        <p>
          <span class="title1 d_ib">歌手:</span>
          <span
            class="color1 cur_p td_u"
            @click="router.push('/artist?id=' + detail.artist.id)"
          >{{ detail.artist.name }}</span>
        </p>
        <p>
          <span class="title2 d_ib">发行时间:</span>
          <span>{{ timeFormat(detail.publishTime) }}</span>
        </p>
        <p>
          <span class="title2 d_ib">发行公司:</span>
          <span>{{ detail.company }}</span>
        </p>
      </div>
      <Feature
        :subscribedIsText="true"
        :shareCount="detail.info.shareCount"
        :subscribedCount="detail.info.likedCount"
        :commentCount="detail.info.commentCount"
        :jumpComments="jumpComments"
      ></Feature>
    </div>
  </div>
  <div class="introduce pr">
    <h3 class="title">专辑介绍：</h3>
    <p class="introduce-content" :class="showIntroduce ? 'show' : ''">{{ detail.description }}</p>
    <div class="btn pa cur_p" @click="showIntroduce = !showIntroduce">
      {{ !showIntroduce ? '展开' : '收起' }}
      <i class="icon_expand_arrow"></i>
    </div>
  </div>
</template>

<script setup lang="ts">
import { PropType, ref } from 'vue'
import { useRouter } from 'vue-router'
import {
  AlbumDetailType,
} from "../../types/types";
import Feature from './feature.vue'
import { pageScrollTop, timeFormat } from '../../utils'

//router实例
const router = useRouter()


const props = defineProps({
  detail: {
    type: Object as PropType<AlbumDetailType>,
    required: true
  }
})

//展示专辑介绍
const showIntroduce = ref(false)

//评论按钮跳转评论区
const jumpComments = function () {
  let h = document.getElementById("comment")?.offsetTop
  if (h) pageScrollTop(h)
}

</script>

<style lang="scss" scoped>
.cover {
  width: 209px;
  height: 177px;
  margin-right: 21px;
  .mask {
    top: 0;
    left: 0;
  }
}
.message {
  flex: 1;
  .row1 {
    height: 24px;
    line-height: 24px;
    margin-bottom: 12px;
    overflow: hidden;
    i {
      margin-right: 10px;
    }
    .name {
      height: 24px;
      line-height: 24px;
      font-size: 20px;
      font-weight: normal;
    }
  }
  .row2 {
    margin-bottom: 20px;
    span {
      line-height: 18px;
      font-size: 12px;
      color: #666;
      &.color1 {
        color: #0c73c2;
      }
      &.title1 {
        width: 36px;
      }
      &.title2 {
        width: 60px;
      }
    }
    p {
      margin-top: 4px;
      line-height: 18px;
    }
  }
}

.introduce {
  margin-top: 20px;
  .title {
    font-size: 12px;
    color: #333;
    height: 16px;
    line-height: 16px;
    font-weight: bold;
  }
  &-content {
    height: 140px;
    display: -webkit-box;
    word-wrap: break-word;
    word-break: break-word;
    white-space: pre-wrap;
    font-size: 12px;
    line-height: 28px;
    color: #666;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 5;
    &.show {
      display: inline-block;
      height: auto;
      + div i {
        transform: rotate(180deg);
      }
    }
  }
  .btn {
    width: 100%;
    text-align: right;
    height: 16px;
    line-height: 16px;
    color: #0c73c2;

    i {
      margin-left: -2px;
      margin-top: 4px;
    }
  }
}
</style>